<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>基本dom结构</title>
</head>
<body>
<div id="box"> </div>
<button id="btnAdd">添加</button>
<button id="btnRemove">移除</button>
</body>
<script>

    var btnAdd = document.getElementById('btnAdd');
    btnAdd.onclick=btnAddClick;

    var btnAdd = document.getElementById('btnRemove');
    btnAdd.onclick=btnRemoveClick;

    function btnAddClick () {

        var box = document.getElementById('box');

        var newBox = document.createElement('div');
        newBox.innerText="new box";

        box.appendChild(newBox);

    }

   function btnRemoveClick(){
       var box = document.getElementById('box');

      // var lastBox=box.children[box.children.length-1] ;
       var lastBox=box.lastChild;

       box.removeChild(lastBox);

   }

</script>
</html>